﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PUCP.SI2.SGIRP.BE;
using PUCP.SI2.SGIRP.BC;

namespace PUCP.SI2.SGIRP.GUI
{
    public partial class ClienteMenuForm : Form
    {
        public int selectedIndex = -1;
        ClienteBC Cliente = new ClienteBC();
        List<ClienteBE> listaCliente = new List<ClienteBE>();

        public ClienteMenuForm()
        {
            InitializeComponent();
            tblCliente.RowCount = 5;
            tblCliente.ColumnCount = 3;
        }

        public void refreshTable()
        {
            tblCliente.Rows.Clear();

            listaCliente = ClienteBC.getAllClientes();

            for (int i = 0; i < listaCliente.Count; i++)
            {
                tblCliente.Rows.Add("" + listaCliente[i].Ruc, "" + listaCliente[i].RazonSocial, listaCliente[i].Estado);
            }
            
            tblCliente.AutoResizeColumns();
            tblCliente.AutoResizeRows();

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void lblCComercial_Click(object sender, EventArgs e)
        {

        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void btnBuscar_Click(object sender, EventArgs e)
        {
            ClienteBC cl = null;
            for (int i = 0; i < listaCliente.Count; i++)
            {
                if (listaCliente[i].Ruc.Equals(txtCodigo.Text))
                {
                    return listaCliente[i];
                }
            }
            return cl;
            
            //tblCliente.AutoResizeColumns();
            //tblCliente.AutoResizeRows();

        }

        private void tsbEliminar_Click(object sender, EventArgs e)
        {
           // MessageBox.Show("¿Desea Deshabilitar el Local con Código L-100?", "Confirmar Eliminar", MessageBoxButtons.YesNoCancel);
        }

        private void tsbMostrar_Click(object sender, EventArgs e)
        {



        }

        private void tsbEditar_Click(object sender, EventArgs e)
        {
            

        }

        private void tsbAgregar_Click(object sender, EventArgs e)
        {
            new NuevoClienteForm().Show();
        }


    }
}
